home *** CD-ROM | disk | FTP | other *** search
Text File | 1998-11-02 | 4.4 KB | 207 lines | [TEXT/CWIE] |
- /*
- * File: SortPicts.h
- * -------------------
- *
- *
- *
- */
-
-
- //#include "SortPictsPrecompile.c"
-
- #ifndef __SortPicts__
- #define __SortPicts__
-
- class SortPicts;
-
- #include "Window.h"
- #include "Sprocket.h"
- #include "Multiprocessing.h"
-
- #include <Threads.h>
- #include <QDOffscreen.h>
- #include <Sound.h>
- //#include <LowMem.h>
-
- #define kUpdateInterval 5;
-
- /*
- * QuickSort #define
- */
- #define kPivotCutoff 25
-
- typedef void (*SortFuncPtr)( SortPicts *sortPicts);
- typedef void (*UpdateFuncPtr)( SortPicts *sortPicts);
-
- typedef unsigned char SortPixel;
- typedef SortPixel *SortPixelPtr;
- typedef SortPixelPtr *SortPixelHandle;
-
- typedef long SortData;
- typedef SortData *SortDataPtr;
- typedef SortDataPtr *SortDataHandle;
-
- #define kYieldTime 4
- #define kWindPictRectVoffset 0
-
- /* The names of windows to open at startup time */
- #define kDefaultWindowResource 100
-
- #include "Window.h"
-
- class SortPicts : public TWindow {
- public:
-
-
- GWorldPtr sortGWorld;
- PixMapHandle sortPixmap;
- SortPixelPtr sortPixels;
- SortDataPtr sortData;
- SortDataHandle sortHandle;
- static long gNumWindowsCreated;
- static short gPrefsRef;
-
- long N;
-
- long pictWidth;
- long pictHeight;
- long pictRowBytes;
-
- Rect updateRect;
- Rect sortRect;
- Rect copyBitsRect;
- Rect windPictRect;
-
- long low, high;
-
- SortFuncPtr sortFunc;
- UpdateFuncPtr updateFunc;
-
- PicHandle sortPict;
- WindowPtr me;
-
- long randomSeed;
-
-
- long startTime;
- long newUnitCount;
- long unitCount;
-
- ThreadID threadInfo;
-
- Boolean coplandTask;
- // TaskName myTaskName;
- MPTaskID myTaskID;
- MPCriticalRegionID sortBlitterBusy;
- unsigned long updateTime;
-
- long horiz;
- long vert;
- long lastHorizLeft;
- long lastHorizRight;
- long pixelVert;
-
- public:
- SortPicts();
- SortPicts( ConstStr255Param name);
- virtual ~SortPicts();
-
- virtual void Idle(EventRecord *anEvent);
- virtual WindowPtr MakeNewWindow(WindowPtr behindWindow);
- virtual void AdjustCursor(EventRecord * anEvent);
- virtual void Activate(Boolean activating);
- virtual void Draw(void);
- virtual void Drag(Point startPoint);
-
- // virtual void Click(EventRecord * anEvent);
- virtual void KeyDown(EventRecord * anEvent);
-
- virtual void AdjustForNewWindowSize(Rect * oldRect,Rect * newRect);
-
- virtual Boolean Close(void);
-
- virtual OSErr HandleDrag(DragTrackingMessage dragMessage,DragReference theDrag);
- virtual OSErr HandleDrop(DragReference theDrag);
-
- Boolean PrepareGWorld( ConstStr255Param pictName);
-
- Boolean LoadSortPicture( ConstStr255Param pictName);
- void ReleaseSortPicture( void);
- Boolean MakeSortGWorld( void);
- Boolean AllocSortData( void);
- void CopyFromSortData( void );
- void ReleaseSortData( void);
- void MakeSortData( void);
- void UseSortData( void);
- void UnuseSortData( void);
- void InitializeSortWindowRect( ConstStr255Param pictName);
- void OpenDefaultSortWindows( void);
- void SelectRandomPicture( void);
-
- Str255 sortPictsName;
- long Random( long num);
- long RandomPixel( void);
- void SetSortItem( long index, long data);
- void ExchangeSortItem( long one, long theOther);
- void Scramble( void);
-
- void UseUpdateFunc( UpdateFuncPtr updateFunc);
- void Update( void);
- void UpdateScramble( void);
- void UpdateSortPict( void);
-
- void Entry( void);
- void MakeThreaded( void);
- void Yield( void);
- void CalculateNewUnitCount( void);
-
- void UseSortFunc( SortFuncPtr sortFunc);
- void Sort( void);
-
- void QSort( void);
- void ChooseMedian( long a, long b, long c);
- void QuickSortEngine( long left, long right);
-
- void HeapSort( void);
- void BuildHeap( void);
- void Heapify( long size, long index);
-
- void ShellSort( void);
- };
-
- void UpdateScramble( SortPicts *sortPicts);
- void UpdateSortPict( SortPicts *sortPicts);
- void QSort( SortPicts *sortPicts);
- void HeapSort( SortPicts *sortPicts);
- void ShellSort( SortPicts *sortPicts);
-
- pascal voidPtr SortPictsThreadEntry( void *there);
-
-
- // menus defined by SortPicts
-
- #ifndef _STANDARDMENUS_
- #include "StandardMenus.h"
- #endif
-
- #define mSprocketFileMenu 256
- #define iNewSortingPict 1
- #define iCloseWindow 2
- #define iQuitSortPicts 4
-
- #define mSortAlgorithm 257
- #define iQuickSort 1
- #define iShellSort 2
- #define iHeapSort 3
- #define iRandomSort 5
- #define iUseCoplandTasks 7
-
- #define mPictureMenu 258
-
- #define kAboutBoxFor68K 256
- #define kAboutBoxForPowerPC 257
- #define iCreditsButton 2
-
- #define kCreditsBox 258
-
- #endif